package com.syq.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.syq.mapper.DtsAddressMapper;
import com.syq.pojo.DtsAddress;
import com.syq.service.DtsAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.xml.ws.soap.Addressing;

/**
 * @ClassName: DtsAddressServiceImpl
 * @Description: TODO
 * @Create by: syq
 * @Date: 2022/7/25 21:59
 */

@Service
public class DtsAddressServiceImpl implements DtsAddressService {

    @Autowired
    private DtsAddressMapper dtsAddressMapper;

    @Override
    public IPage<DtsAddress> findByPage(Integer page, Integer limit, String name, Integer userId, String sort, String order) {
        return dtsAddressMapper.selectPage(new Page<>(page, limit),
                new QueryWrapper<DtsAddress>()
                        .like(!StringUtils.isEmpty(name),"name",name)
                        .eq(!StringUtils.isEmpty(userId),"id",userId)
                        .orderBy(!StringUtils.isEmpty(sort),order.equalsIgnoreCase("Asc"),sort));
    }
}
